package com.example.springboot.email.service;

import com.example.springboot.email.bean.HttpResult;
import com.example.springboot.email.bean.UserInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping(value="/hello",method = RequestMethod.GET)
    public String hello(String name){

        return "Hello world! "+name +" I like you!" ;
    }

    @RequestMapping(value="/say",method = RequestMethod.POST)
    public HttpResult sayHello(@RequestParam String name,@RequestParam int age){

        HttpResult result = new HttpResult();
        UserInfo info = new UserInfo();
        info.setUsername(name);
        info.setPhone("123456678900");
        result.setData(info);

        result.setCode(100);
        result.setMsg(name +" say Hello to you and age is "+age);


        return result;
    }
}
